package com.zjw.designPattern.singleton;

/**
 * 懒汉式，线程不安全(时间换空间)
 * */
public class Singleton {

    private Singleton() {
    }

    private static Singleton singleton = null;

    //静态方法是在被调用时才执行，故为懒汉式(static 代码块是在程序启动时就执行)
    public static Singleton getInstance(){
        if(singleton == null){
            singleton = new Singleton();
        }

        return singleton;
    }
}
